﻿// ***********************************************************************
// Assembly         : Logica
// Author           : Diego
// Created          : 03-02-2014
//
// Last Modified By : Diego
// Last Modified On : 03-02-2014
// ***********************************************************************
// <copyright file="LOG_Material.cs" company="">
//     Copyright (c) . All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using AccesoDatos.Modulos.ClasesAccesoDatos;
using Modelado.Modulos.ClasesModelado;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/// <summary>
/// The ClasesLogica namespace.
/// </summary>
namespace Logica.Modulos.ClasesLogica
{
    /// <summary>
    /// Class LOG_Material.
    /// </summary>
    public class LOG_Material : Negocio
    {

        //insertar Inserta Material
        /// <summary>
        /// Crs the e_ material.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <returns>System.Int32.</returns>
        public int CRE_Material(MOD_Material obj)
        {
            try
            {
                this.IniciarTransaccion();

                AD_Material objBD = new AD_Material();

                int codigo = objBD.CRE_Material(this.comando, obj);

                this.ConfirmarTransaccion();

                return codigo;
            }
            catch (Exception exc)
            {
                this.DeshacerTransaccion();
                throw exc;
            }
        }


       // Elimina Material
        /// <summary>
        /// Des the l_ material.
        /// </summary>
        /// <param name="codigo">The codigo.</param>
        public void DEL_Material(int codigo)
        {
            try
            {
                this.IniciarTransaccion();

                AD_Material objBD = new AD_Material();

                objBD.DEL_Material(this.comando, codigo);

                this.ConfirmarTransaccion();
            }
            catch (Exception exc)
            {
                this.DeshacerTransaccion();
                throw exc;
            }
        }
        //Actualiza Material
        /// <summary>
        /// Ups the d_ material.
        /// </summary>
        /// <param name="obj">The object.</param>
        public void UPD_Material(MOD_Material obj)
        {
            try
            {
                this.IniciarTransaccion();

                AD_Material objBD = new AD_Material();

                objBD.UPD_Material(this.comando, obj);

                this.ConfirmarTransaccion();
            }
            catch (Exception exc)
            {
                this.DeshacerTransaccion();
                throw exc;
            }
            
        }


        //consultar grid material

        /// <summary>
        /// Ses the l_ grid_ materiales.
        /// </summary>
        /// <returns>List{MOD_Material}.</returns>
        public List<MOD_Material> SEL_Grid_Materiales()
        {
            try
            {
                this.AbrirConexion();

                AD_Material objBD = new AD_Material();

                List<MOD_Material> lista = objBD.SEL_Grid_Materiales(this.comando);

                this.CerrarConexion();

                return lista;
            }
            catch (Exception exc)
            {
                this.CerrarConexion();
                throw exc;
            }
        }



        //Seleccionar material by id
        /// <summary>
        /// Ses the l_ material by identifier.
        /// </summary>
        /// <param name="codMaterial">The cod material.</param>
        /// <returns>MOD_Material.</returns>
        public MOD_Material SEL_MaterialByID(int codMaterial)
        {
            try
            {
                this.AbrirConexion();

                AD_Material objBD = new AD_Material();

                MOD_Material objMaterial = objBD.SEL_MaterialByID(this.comando, codMaterial);

                this.CerrarConexion();

                return objMaterial;
            }
            catch (Exception exc)
            {
                this.CerrarConexion();
                throw exc;
            }

        }

        // Selecicona unidad de medida , Llena Combobox
        /// <summary>
        /// Ses the l_ co d_ medida.
        /// </summary>
        /// <returns>List{MOD_Unidad_Medida}.</returns>
        public List<MOD_Unidad_Medida> SEL_COD_MEDIDA()
        {
            try
            {
                this.AbrirConexion();

                AD_Material objBD = new AD_Material();

                List<MOD_Unidad_Medida> lista = objBD.SEL_COD_MEDIDA(this.comando);

                this.CerrarConexion();

                return lista;
            }
            catch (Exception exc)
            {
                this.CerrarConexion();
                throw exc;
            }
        }

    }
}

